<template>
	<view class="ljapp my-withdraw">
		<lj-top-tip type="info" :text="'每月'+withdraw_date_min+'-'+withdraw_date_max+'号提现，当月'+withdraw_date_pay+'号到账'"></lj-top-tip>

		<view class="header">
			<view class="top">
				<view class="tit">提现金额(元)</view>
				<view class="money">￥ {{doctorobj.money}}</view>
			</view>
			<view class="bottom">
				<view class="item u-flex u-flex-between">
					<view>提现账户</view>
					<view>{{payway=='wx'?'微信':'支付宝'}}</view>
				</view>
				<view class="item u-flex u-flex-between">
					<view>提现单号</view>
					<view>{{order_code}}</view>
				</view>
				<view class="item u-flex u-flex-between">
					<view>创建时间</view>
					<view>{{$u.timeFormat(createtime, 'yyyy-mm-dd hh:MM:ss')}}</view>
				</view>
			</view>
		</view>
		
		<view class="content">
			<view class="tit">选择提现账户</view>
			<view class="cellbox">
				<view class="item u-flex u-flex-between">
					<view class="u-flex">
						<image class="licon" src="/static/lj/common/weixin.png" mode="aspectFill"></image>
						<view>微信</view>
					</view>
					<view>
						<image class="ricon" :src="'/static/lj/common/radio'+(payway=='wx'?'-checked':'')+'.png'" mode="aspectFill"></image>
					</view>
				</view>
				<view class="item u-flex u-flex-between" v-if="false">
					<view class="u-flex">
						<image class="licon" src="/static/lj/common/ali.png" mode="aspectFill"></image>
						<view>支付宝</view>
					</view>
					<view>
						<image class="ricon" :src="'/static/lj/common/radio'+(payway=='ali'?'-checked':'')+'.png'" mode="aspectFill"></image>
					</view>
				</view>
			</view>
		</view>
	
		<view class="btn-fillet" @click="submit">提现</view>
		
		<u-popup :show="show" :round="8" mode="center">
			<view class="popup-submit-content">
				<view class="tit">提交成功，待财务审核</view>
				<view class="con">（{{popupSubmitTime}}s后自动关闭）</view>
			</view>
		</u-popup>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				tiptxt: '',
				
				order_code: '',
				createtime: '',
				withdraw_date_min: '',
				withdraw_date_max: '',
				withdraw_date_pay: '',
				
				payway: 'wx',
				show: false,
				popupSubmitTimer: null,
				popupSubmitTime: 5,
				
				doctorobj: {}, //详情
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init(){
				this.$Http({
					url: 'getUserInfo',
					data: {},
					type:'POST',
				}).then(res => {
					if (res.code == 1) {
						this.doctorobj = res.data.doctor_info
					}
				});
				this.$Http({
					url: 'doctorWithdraw',
					data: {},
				}).then(res => {
					if (res.code == 1) {
						this.order_code = res.data.order_code
						this.withdraw_date_min = res.data.withdraw_date_min
						this.withdraw_date_max = res.data.withdraw_date_max
						this.withdraw_date_pay = res.data.withdraw_date_pay
					}
				});
			},
			submit(){
				var that = this
				
				this.$Http({
					url: 'doctorWithdraw',
					data: {
						money: this.doctorobj.money
					},
					type:'POST',
					show:true,
				}).then(res => {
					if (res.code == 1) {
						that.show = true
						that.popupSubmitTime = 5
						that.popupSubmitTimer = setInterval(function(){
							that.popupSubmitTime--
							if(that.popupSubmitTime<=0){
								that.show = false
								if(that.popupSubmitTimer!=null){
									clearInterval(that.popupSubmitTimer)
									that.popupSubmitTimer = null
									uni.navigateBack()
								}
							}
						},1000)
						
						that.init();
					}
				});
			},
		}
	}
</script>

<style lang="less">
	@import '@/pagesL/style.less';
</style>
